

<div class="content-box">


	<div class="content-box-header">
		<h3>用户信息</h3>
	</div>
	<!-- End .content-box-header -->

	<div class="content-box-content">

		<div class="tab-content default-tab">

			<table>

				<thead>
					<tr>
						<th>学号</th>
						<th>姓名</th>
						<th>邮箱</th>
						<th>学校</th>
						<th>专业</th>
						<th>小组</th>
						<th>角色</th>
						<th>注册时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>

				</thead>

				<tfoot>
			
					<tr>
						<td colspan="3">
							<div class="clear"></div></td>
					</tr>
				</tfoot>

				<tbody>
				{% for user in users %}
					<tr id="{{user.student_id}}">
						<td>{{user.student_id}}</td>
						<td>{{user.name}}</td>
						<td>{{user.email}}</td>
						<td>{{user.school}}</td>
						<td>{{user.major}}</td>
						<td>{{user.group.name}}</td>
						<td>
						{% ifequal user.group.administrator user %}
						<span style="color:red">组长</span>
						{% else %}
						组员
						{% endifequal %}
						
						{%if user.auth_user.is_staff%}
						<span class="ta" style="">|TA</span>
						{% else %}
						<span class="ta" style="display:none">|TA</span>
						{% endif%}
						
						</td>
						<td>{{user.auth_user.date_joined}}</td>
						
						{% if user.auth_user.is_active%}
						<td>
						<span class="active" style="color:green;">已激活</span>
						<span class="unactive" style="color:red;display:none">未激活</span>
						</td>
						{% else %}
						<td>
						<span class="active" style="color:green;display:none">已激活</span>
						<span class="unactive" style="color:red;">未激活</span>
						</td>
						{% endif %}
						<td>
						{% if user.auth_user.is_active%}
						<a class="active_link" id="active_link_{{user.student_id}}" name="{{user.student_id}}" href="javascript:void(0);" style="display:none">激活</a>
						<a class="unactive_link" id="unactive_link_{{user.student_id}}" name="{{user.student_id}}"  href="javascript:void(0);">禁用</a>
						{% else %}
						<a class="active_link" id="active_link_{{user.student_id}}" name="{{user.student_id}}" href="javascript:void(0);" >激活</a>
						<a class="unactive_link" id="unactive_link_{{user.student_id}}" name="{{user.student_id}}"  href="javascript:void(0);" style="display:none">禁用</a>
						{% endif %}
						
						|
						{% if user.auth_user.is_staff%}
						<a class="setta_link"  name="{{user.student_id}}" href="javascript:void(0);" style="display:none">设为TA</a>
						<a class="unsetta_link" name="{{user.student_id}}"  href="javascript:void(0);">取消TA</a>
						{% else %}
						<a class="setta_link"  name="{{user.student_id}}" href="javascript:void(0);" >设为TA</a>
						<a class="unsetta_link"  name="{{user.student_id}}"  href="javascript:void(0);" style="display:none">取消TA</a>
						{% endif %}
						
						</td>
					
					</tr>
				{% endfor %}
				</tbody>

			</table>

		</div>
		<!-- End #tab3 -->

	</div>
	<!-- End .content-box-content -->

</div>
<script type="text/javascript" >

$.each($('.active_link'),function(index,obj){
	if($(obj).attr('name')!='')
		$(obj).bind('click',function(event)
				{
					$.get("pass_user",
					{"user":$(obj).attr('name')},
						function(json)
						{
							if(json.error)
				    		{
				    			Boxy.alert("激活失败，请检查您的信息"+json.error_type, function() {}, {title: '错误'});
				    		}
				    		else
				    		{
				    				$("#"+$(obj).attr('name')+" .active_link").hide();
				    				$("#"+$(obj).attr('name')+" .unactive").hide();
				    				$("#"+$(obj).attr('name')+" .unactive_link").show();
				    				$("#"+$(obj).attr('name')+" .active").show();
				    		}
						},
						"json");	
		});

});

$.each($('.setta_link'),function(index,obj){
	if($(obj).attr('name')!='')
		$(obj).bind('click',function(event)
				{
					$.get("set_user_TA",
					{"user":$(obj).attr('name')},
						function(json)
						{
							if(json.error)
				    		{
				    			Boxy.alert("设置TA失败，请检查您的信息"+json.error_type, function() {}, {title: '错误'});
				    		}
				    		else
				    		{
				    				$("#"+$(obj).attr('name')+" .setta_link").hide();
				    				$("#"+$(obj).attr('name')+" .unsetta_link").show();
				    				$("#"+$(obj).attr('name')+" .ta").show();
				    		}
						},
						"json");	
		});

});

$.each($('.unsetta_link'),function(index,obj){
	if($(obj).attr('name')!='')
		$(obj).bind('click',function(event)
				{
					$.get("remove_user_TA",
					{"user":$(obj).attr('name')},
						function(json)
						{
							if(json.error)
				    		{
				    			Boxy.alert("取消TA失败，请检查您的信息"+json.error_type, function() {}, {title: '错误'});
				    		}
				    		else
				    		{
				    				$("#"+$(obj).attr('name')+" .setta_link").show();
				    				$("#"+$(obj).attr('name')+" .unsetta_link").hide();
				    				$("#"+$(obj).attr('name')+" .ta").hide();
				    		}
						},
						"json");	
		});

});
$.each($('.unactive_link'),function(index,obj){
	if($(obj).attr('name')!='')
		$(obj).bind('click',function(event)
				{
					$.get("delete_user",
					{"user":$(obj).attr('name')},
						function(json)
						{
							if(json.error)
				    		{
				    			Boxy.alert("禁用失败，请检查您的信息"+json.error_type, function() {}, {title: '错误'});
				    		}
				    		else
				    		{
				    				$("#"+$(obj).attr('name')+" .unactive_link").hide();
				    				$("#"+$(obj).attr('name')+" .active").hide();
				    				$("#"+$(obj).attr('name')+" .active_link").show();
				    				$("#"+$(obj).attr('name')+" .unactive").show();
				    		}
						},
						"json");	
		});

});
</script>


<!-- End .content-box -->